<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>登录</title>
	<link rel="icon" href="">
	<link rel="stylesheet" type="text/css" href="/static/css/aui.css" />
</head>
<body>
<!-- 头部 -->
	<header class="aui-bar aui-bar-nav" id="header" style="background-color: #00bcd4;padding-top: 10px;">
	    <a class="aui-pull-left aui-btn" href="{% url 'mycampus:login' %}">
	        <span class="aui-iconfont aui-icon-left"></span>
	    </a>
	    <div class="aui-title">找回密码</div>
	</header>
	<div id="header-bottom"></div>
    <section class="aui-content-padded">
	        <div class="aui-content">
	            <div class="aui-content aui-margin-b-15">
			        <ul class="aui-list aui-form-list">
			        	<li class="aui-list-item">
			                <div class="aui-list-item-inner">
			                    <div class="aui-list-item-input">
			                        <input type="text" placeholder="请输入邮箱" required="required" name="email" id="email" >
			                    </div>
			                    <div class="aui-list-item-label">
			                        <button class="btn btn-primary" onclick="ajax_request()" id="check" style="background-color: #00bcd4 !important;">获取验证码</button>
			                    </div>
			                </div>
			            </li>
			            <li class="aui-list-item">
			                <div class="aui-list-item-inner">
			                    <div class="aui-list-item-input">
			                        <input type="text" class="" placeholder="请输入验证码"  name="checkcode" id="checkcode">
			                    </div>
			                    <div class="aui-list-item-label">
			                        <button  class="btn btn-primary block full-width m-b" onclick="ajax_request1()" style="background-color: #00bcd4 !important;">找回密码</button>
			                    </div>
			                </div>
			            </li>
			            <li>
			            	<div><span id="result"></span></div>
			            </li>
			        </ul>
			    </div>
	        </div><!-- endcontent -->
	</section>
	<script src="/static/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="/static/js/api.js"></script>
	<script type="text/javascript">
	    apiready = function(){
		        if(api.systemType == 'ios'){
		            scaleEnabled = true;
		            // document.getElementById('header').style.paddingTop = '10px';
		        }
                //支持沉浸式效果
		        if (!api.statusBarAppearance) {
		           document.getElementById('header').style.paddingTop = '0px';
		        }
	        };
	</script>
<script>
var wait = 60;
var check = document.getElementById("check");
      function time() {
          if (wait == 0) {
              check.removeAttribute("disabled");
              check.innerHTML = "获取验证码";
              wait = 60;
         } else {
             check.setAttribute("disabled", true);
             check.innerHTML = wait + "秒后可以重新发送";
             wait--;
             setTimeout(function() {
                 time()
             }, 1000)
         }
     }
function ajax_request()
{
time();
var xmlhttp;
if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      // document.getElementById("result").innerHTML=xmlhttp.responseText;
      if(xmlhttp.responseText==""){ 
      }else{

      }
  }
}

var email = document.getElementById("email").value;
xmlhttp.open("GET", "/mycampus/setEmail?email=" + email, true);
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlhttp.send();
// ajax 教程：http://www.ziqiangxuetang.com/ajax/ajax-tutorial.html
}
function ajax_request1()
{
var xmlhttp;
if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      // document.getElementById("result").innerHTML=xmlhttp.responseText;
      if(xmlhttp.responseText==""){ 
        document.getElementById("result").innerHTML="";
        window.location.href="/mycampus/rePassword"; 
      }else{
        document.getElementById("result").innerHTML="<font color=\"red\">"+xmlhttp.responseText+"</font>";
      }
  }
}

var email = document.getElementById("email").value;
var checkcode = document.getElementById("checkcode").value;
xmlhttp.open("GET", "/mycampus/check?email=" + email+"&&checkcode="+checkcode, true);
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlhttp.send();
// ajax 教程：http://www.ziqiangxuetang.com/ajax/ajax-tutorial.html
}
</script> 
</body>
</html>